Reorganize main update function
authorjustbur <justin@burkett.cc>
Thu, 2 Jul 2015 12:27:29 +0000 (08:27 -0400)
committerjustbur <justin@burkett.cc>
Thu, 2 Jul 2015 12:33:23 +0000 (08:33 -0400)
which-key.el

index c93340891b9d4c0045026371eaf76c763e56d082..b3ca76f5232d241567c4f29dc7a8481b6af85a76 100644 (file)
@@ -121,8 +121,8 @@ replace and the cdr is the replacement text. "
             (bottom-or-top (member which-key-buffer-position '(top bottom)))
             (max-len-key 0) (max-len-desc 0) key-match desc-match
             unformatted formatted buffer-height buffer-width vertical-buffer-width)
-        (with-current-buffer (get-buffer which-key-buffer)
-          (erase-buffer)
+        ;; get keybindings
+        (with-temp-buffer
           (describe-buffer-bindings buf key)
           (goto-char (point-max))
           (while (re-search-backward
@@ -135,18 +135,18 @@ replace and the cdr is the replacement text. "
             (cl-pushnew (cons key-match desc-match) unformatted
                         :test (lambda (x y) (string-equal (car x) (car y)))))
           (setq max-len-desc (if (> max-len-desc which-key-max-description-length)
-                                 (+ 2 which-key-max-description-length)
+                                 (+ 2 which-key-max-description-length) ; for the ..
                                max-len-desc))
           (setq formatted (mapcar (lambda (str)
                                     (which-key/format-matches str max-len-key max-len-desc))
-                                  unformatted))
+                                  unformatted)))
+        (with-current-buffer (get-buffer which-key-buffer)
           (erase-buffer)
           (setq vertical-buffer-width (which-key/get-vertical-buffer-width max-len-desc max-len-key))
           (setq buffer-line-breaks
                 (which-key/insert-keys formatted (unless bottom-or-top vertical-buffer-width)))
           (goto-char (point-min))
           (which-key/replace-strings-from-alist which-key-description-replacement-alist)
-          ;; (message "%s" which-key-vertical-buffer-width)
           (if bottom-or-top
               (setq buffer-height (+ 2 buffer-line-breaks))
             (setq buffer-width vertical-buffer-width)))